/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-01-07
 * Time: 14:59
 */
public class test2 {
    /*
    LeetCode 121  买卖股票的最佳时机
     */
    public int maxProfit(int[] prices) {
        int min = Integer.MAX_VALUE;
        int ret = 0;
        int n = prices.length;
        for(int i=0;i<n;i++){
            if(min>prices[i]){
                min = prices[i];
            }else if(prices[i]-min>ret){
                ret = prices[i]-min;
            }
        }
        return ret;
    }
}
